package com.ruoyi.web.controller.kaoyan.vo;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.kaoyan.domain.EducationFileInfo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;
import java.util.Optional;

/**
 * 分享的资料vo类
 * @author admin
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class FileInfoVo {

    private Long id;

    private String userName;

    private String categoryName;

    private String fileName;

    private String verFlag;

    public FileInfoVo(EducationFileInfo fileInfo, Map<Long, String> categoryNameMap, Map<Long, String> userNameMap) {
        this.id = fileInfo.getId();
        this.fileName = fileInfo.getName();
        String categoryName = categoryNameMap.get(fileInfo.getCategoryId());
        this.categoryName = Optional.ofNullable(categoryName).orElse("");
        String userName = userNameMap.get(fileInfo.getUserId());
        this.userName = Optional.ofNullable(userName).orElse("");
        this.verFlag = StringUtils.isNull(fileInfo.getVerFlag()) ? "null" : String.valueOf(fileInfo.getVerFlag());
    }
}
